00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #include <iostream>
00028 #include <libxml/parser.h>
00029 #include <libxml/tree.h>
00030
00031 #include <string>
00032 #include <muo.h>
00033 #include <popt.h>
00034 #include <time.h>
00035 #include "mrprjContent.h"
00036 #include "cmdline.h"
00037
00038 int main (int argn, char * argv[])
00039 {
00040 gengetopt_args_info args_info;
00041
00042 if (cmdline_parser(argn,argv, &args_info)!=0)
00043 {
00044 cerr << "grrr: gengetopt-args can't be parsed\n";
00045 exit(-1);
00046 }
00047
00048 int messLevel=SM;
00049 if (args_info.debug_flag)
00050 messLevel=HM;
00051
00052 krmuo::LoggingUnit faultLogging(messLevel,stderr);
00053
00054
00055 string xmlFileName="stdin";
00056 FILE *fp;
00057 if (args_info.dbFile_given)
00058 {
00059 xmlFileName=args_info.dbFile_arg;
00060 fp=fopen(args_info.dbFile_arg,"r");
00061 if (!(fp))
00062 {
00063 faultLogging.makeEntry("Can't open/found inputfile",xmlFileName,SIGNAL_MESSAGE);
00064 exit(-1);
00065 }
00066 }
00067 else
00068 {
00069 fp=stdin;
00070 }
00071
00072 char sign;
00073 string xmlFileContent;
00074 do
00075 {
00076 sign=fgetc(fp);
00077 if ((sign!=EOF))
00078 xmlFileContent+=sign;
00079 }
00080 while(sign!=EOF);
00081
00082 if (fp!=stdin)
00083 fclose(fp);
00084
00085 string resourceGroupNameString="all";
00086 string resourceNameString="all";
00087 string timeSlotEndString="21001231T240000";
00088 string timeSlotStartString="19700101T000000";
00089 string surveyReferenceDayString="20020535T256363";
00090
00091 if (args_info.rwHtmlSurvey_flag)
00092 {
00093 if (args_info.evaluationDate_given)
00094 surveyReferenceDayString=args_info.evaluationDate_arg;
00095 else
00096 {
00097 time_t now;
00098
00099 if (time(&now))
00100 {
00101 struct tm* tp;
00102 char timeStamp[20];
00103 tp=localtime(&now);
00104 strftime(timeStamp,20,"%Y%m%dT%H%M%S",tp);
00105 surveyReferenceDayString=timeStamp;
00106 }
00107 }
00108 }
00109 else
00110 {
00111 if (args_info.timeSlotStart_given)
00112 timeSlotStartString=args_info.timeSlotStart_arg;
00113
00114 if (args_info.timeSlotEnd_given)
00115 timeSlotEndString=args_info.timeSlotEnd_arg;
00116
00117 if (args_info.person_given)
00118 resourceNameString=args_info.person_arg;
00119
00120 if (args_info.group_given)
00121 resourceGroupNameString=args_info.group_arg;
00122 }
00123
00124 if (args_info.debug_flag)
00125 {
00126 string resourceMessage=("concerning the persons/resources: "+resourceNameString);
00127 if (resourceGroupNameString!="all")
00128 resourceMessage=("concerning all persons of group:" +resourceGroupNameString);
00129
00130 string doing= "extracting data from " +
00131 xmlFileName +
00132 "\n " + resourceMessage +
00133 "\n and the timeslot " +
00134 timeSlotStartString +
00135 " - " +
00136 timeSlotEndString +
00137 "\n";
00138
00139 faultLogging.makeEntry(doing,SIGNAL_MESSAGE);
00140 }
00141
00142 mrprj::TaskField mrProjectTaskField(faultLogging);
00143
00144 if (!(mrProjectTaskField.fillTaskFieldByMrPrjXmlFileContent(faultLogging,xmlFileContent)))
00145 {
00146 faultLogging.makeEntry("The given mrprjBaseFile can't be analyzed",xmlFileName,SIGNAL_MESSAGE);
00147 return -1;
00148 }
00149
00150 if (args_info.rwHtmlSurvey_flag)
00151 {
00152 mrProjectTaskField.printTaskHtmlSurvey(surveyReferenceDayString);
00153 return 0;
00154 }
00155
00156
00157 if (args_info.group_given)
00158 {
00159 mrProjectTaskField.limitToResourceGroup(resourceGroupNameString);
00160 }
00161 else
00162 {
00163 if (args_info.person_given)
00164 mrProjectTaskField.limitToResource(resourceNameString);
00165 }
00166
00167 mrProjectTaskField.limitToTimeSlot(timeSlotStartString,timeSlotEndString);
00168
00169 if ((args_info.onlyOpenTasks_flag)||(args_info.only_open_flag))
00170 mrProjectTaskField.limitToOpenTasks();
00171
00172 mrProjectTaskField.limitToThoseWithActiveDaughters();
00173
00174 if (((bool)args_info.rwOnlyLeafs_flag)||((bool)args_info.only_leafs_flag))
00175 {
00176 if (((bool)args_info.rwMemoFile_flag)||((bool)args_info.output_memo_flag))
00177 mrProjectTaskField.printTaskFieldAsLeafListMemo((bool)args_info.rwIso8601_flag||(bool)args_info.iso_dates_flag);
00178 else if (((bool)args_info.rwPilotFile_flag)||((bool)args_info.output_pilot_flag))
00179 mrProjectTaskField.printTaskFieldAsPilotLeafTodo();
00180 else if (((bool)args_info.rwVcardFile_flag)||((bool)args_info.output_vcard_flag))
00181 mrProjectTaskField.printTaskFieldAsLeafVTodo();
00182 else if (((bool)args_info.rwYankFile_flag)||((bool)args_info.output_yank_flag))
00183 mrProjectTaskField.printTaskFieldAsLeafYankTodo();
00184 else if (((bool)args_info.rwCslFile_flag)||((bool)args_info.output_csl_flag))
00185 mrProjectTaskField.printTaskFieldAsLeafCslTodo();
00186 else
00187 mrProjectTaskField.printTaskFieldAsMrPrjXmlFile();
00188 }
00189 else
00190 {
00191 if (((bool)args_info.rwMemoFile_flag)||((bool)args_info.output_memo_flag))
00192 mrProjectTaskField.printTaskFieldAsTreeMemo((bool)args_info.rwIso8601_flag||(bool)args_info.iso_dates_flag);
00193 else if (((bool)args_info.rwPilotFile_flag)||((bool)args_info.output_pilot_flag))
00194 mrProjectTaskField.printTaskFieldAsPilotTreeTodo();
00195 else if (((bool)args_info.rwVcardFile_flag)||((bool)args_info.output_vcard_flag))
00196 mrProjectTaskField.printTaskFieldAsTreeVTodo();
00197 else if (((bool)args_info.rwYankFile_flag)||((bool)args_info.output_yank_flag))
00198 mrProjectTaskField.printTaskFieldAsTreeYankTodo();
00199 else if (((bool)args_info.rwCslFile_flag)||((bool)args_info.output_csl_flag))
00200 mrProjectTaskField.printTaskFieldAsTreeCslTodo();
00201 else
00202 mrProjectTaskField.printTaskFieldAsMrPrjXmlFile();
00203 }
00204
00205 return 0;
00206 }