예제 #1
0
 //NamedValues1
 public override bool TrySetValues(NamedValues <ZValue> values)
 {
     if (!base.TrySetValues(values))
     {
         return(false);
     }
     _weekEnd = false;
     _extra   = false;
     _focus   = false;
     if (values.ContainsKey("we"))
     {
         _weekEnd = true;
     }
     if (values.ContainsKey("extra"))
     {
         _extra = true;
     }
     if (values.ContainsKey("focus"))
     {
         _focus = true;
     }
     if (values.ContainsKey("type_code"))
     {
         SetType((string)values["type_code"]);
     }
     return(true);
 }
예제 #2
0
파일: LeMonde0.cs 프로젝트: labeuze/source
 //NamedValues1
 public static LeMondeType GetType(NamedValues<ZValue> values)
 {
     LeMondeType type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
     }
     else if (values.ContainsKey("type_quo") && values["type_quo"] != null)
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             object o = values["types_quo_sup"];
             if (o != null && !(o is string[]))
                 throw new PBException("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
             foreach (string s in (string[])o)
                 type |= GetTypeSup(s);
         }
     }
     else
     {
         if (!values.ContainsKey("type_sup"))
             throw new PBException("error creating LeMonde unknow type_sup");
         object o = values["type_sup"];
         if (!(o is string))
             throw new PBException("error creating LeMonde value type_sup should be a string : {0}", o);
         type = GetTypeSup((string)o);
     }
     return type;
 }
예제 #3
0
파일: LeMonde0.cs 프로젝트: 24/source_04
 //NamedValues1
 public LeMonde0(NamedValues <ZValue> values)
 {
     // year          : mandatory, int or numeric string
     // day           : mandatory, int or numeric string
     // month         : mandatory, int or numeric string
     // type_quo      : optional, string null, "_quo"
     // types_quo_sup : optional, string[], "tv", "argent"
     // type_sup      : optional, string null, "livres"
     // number        : not used, int or numeric string
     // type          : not used, string "_quo", "-livres", "_quo+tv", "_quo+tv+argent"
     if (!values.ContainsKey("year"))
     {
         throw new PBException("error creating LeMonde unknow year");
     }
     if (!values.ContainsKey("month"))
     {
         throw new PBException("error creating LeMonde unknow month");
     }
     if (!values.ContainsKey("day"))
     {
         throw new PBException("error creating LeMonde unknow day");
     }
     _date = zdate.CreateDate(values);
     _type = GetType(values);
 }
예제 #4
0
파일: LeFigaro.cs 프로젝트: labeuze/source
 //NamedValues1
 public LeFigaro(NamedValues<ZValue> values)
 {
     if (!values.ContainsKey("day_near_current_date"))
     {
         if (!values.ContainsKey("year"))
             throw new PBException("error creating LeFigaro unknow year");
         if (!values.ContainsKey("month"))
             throw new PBException("error creating LeFigaro unknow month");
         if (!values.ContainsKey("day"))
             throw new PBException("error creating LeFigaro unknow day");
     }
     _date = zdate.CreateDate(values);
 }
예제 #5
0
파일: LExpress.cs 프로젝트: labeuze/source
 //NamedValues1
 public override bool TrySetValues(NamedValues<ZValue> values)
 {
     if (!base.TrySetValues(values))
         return false;
     if (values.ContainsKey("es"))
         _es = true;
     if (values.ContainsKey("styles"))
         _styles = true;
     if (values.ContainsKey("type_code"))
         //string
         SetType((string)values["type_code"]);
     return true;
 }
예제 #6
0
 //NamedValues1
 public override bool TrySetValues(NamedValues<ZValue> values)
 {
     if (!base.TrySetValues(values))
         return false;
     _eco = false;
     _mag = false;
     if (values.ContainsKey("eco"))
         _eco = true;
     if (values.ContainsKey("mag"))
         _mag = true;
     if (values.ContainsKey("type_code"))
         SetType((string)values["type_code"]);
     return true;
 }
예제 #7
0
파일: Print.cs 프로젝트: 24/source_04
        protected virtual bool TryGetPrintNumber(NamedValues <ZValue> values, out int number)
        {
            number = 0;
            if (!values.ContainsKey("number"))
            {
                SetError("error print number not found");
                return(false);
            }
            int number2;

            if (!int.TryParse((string)values["number"], out number2))
            {
                SetError("error invalid print number \"{0}\"", values["number"]);
                return(false);
            }
            if (_print.Frequency != PrintFrequency.Daily && !_special)
            {
                //Date date = _print.GetPrintDate(number2);
                Date     date;
                DateType dateType;
                _print.GetPrintDate(number2, out date, out dateType);
                string error;
                if (!ControlDate(date, out error))
                {
                    return(false);
                }
            }
            number = number2;
            return(true);
        }
예제 #8
0
파일: Print.cs 프로젝트: 24/source_04
        protected virtual bool TryGetIndex(NamedValues <ZValue> values, out int index)
        {
            index = 0;
            if (!values.ContainsKey("index"))
            {
                SetError("error index not found");
                return(false);
            }
            //string
            string s = (string)values["index"];

            if (s == null)
            {
                return(true);
            }
            int index2;

            if (!int.TryParse(s, out index2))
            {
                SetError("error invalid index \"{0}\"", s);
                return(false);
            }
            index = index2;
            return(true);
        }
예제 #9
0
        public static object[] GetParameters(MethodInfo methodInfo, NamedValues <ZValue> namedParameters, ErrorOptions option = ErrorOptions.None)
        {
            if (methodInfo == null)
            {
                return(null);
            }
            List <object> parameters = new List <object>();

            //ParameterInfo[] methodParameters = methodInfo.GetParameters();
            foreach (ParameterInfo parameter in methodInfo.GetParameters())
            {
                object value;
                if (namedParameters != null && namedParameters.ContainsKey(parameter.Name))
                {
                    // no control between parameter type and named parameter type
                    value = namedParameters[parameter.Name].ToObject();
                }
                else if (parameter.HasDefaultValue)
                {
                    value = parameter.DefaultValue;
                }
                else
                {
                    Error.WriteMessage(option, $"no value for parameter \"{parameter.Name}\" of method \"{methodInfo.zGetName()}\", use default value");
                    value = zReflection.GetDefaultValue(parameter.ParameterType);
                }
                parameters.Add(value);
            }
            return(parameters.ToArray());
        }
예제 #10
0
 public static object[] GetParameters(MethodInfo methodInfo, NamedValues<ZValue> namedParameters, ErrorOptions option = ErrorOptions.None)
 {
     if (methodInfo == null)
         return null;
     List<object> parameters = new List<object>();
     //ParameterInfo[] methodParameters = methodInfo.GetParameters();
     foreach (ParameterInfo parameter in methodInfo.GetParameters())
     {
         object value;
         if (namedParameters != null && namedParameters.ContainsKey(parameter.Name))
         {
             // no control between parameter type and named parameter type
             value = namedParameters[parameter.Name].ToObject();
         }
         else if (parameter.HasDefaultValue)
         {
             value = parameter.DefaultValue;
         }
         else
         {
             Error.WriteMessage(option, $"no value for parameter \"{parameter.Name}\" of method \"{methodInfo.zGetName()}\", use default value");
             value = zReflection.GetDefaultValue(parameter.ParameterType);
         }
         parameters.Add(value);
     }
     return parameters.ToArray();
 }
예제 #11
0
        // type_dossier  : name
        public override bool TrySetValues(NamedValues <ZValue> values)
        {
            if (!base.TrySetValues(values))
            {
                return(false);
            }

            LeMondeType type;

            if (!TryGetType(values, out type))
            {
                return(false);
            }
            if (type != LeMondeType.Unknow)
            {
                _type = type;
            }

            if (values.ContainsKey("type_dossier"))
            {
                ZValue v = values["type_dossier"];
                if (v != null && v is ZString)
                {
                    _dossier = (string)v;
                }
            }

            _typeCode = null;
            return(true);
        }
예제 #12
0
 //NamedValues1
 public override bool TrySetValues(NamedValues<ZValue> values)
 {
     if (!base.TrySetValues(values))
         return false;
     _weekEnd = false;
     _extra = false;
     _focus = false;
     if (values.ContainsKey("we"))
         _weekEnd = true;
     if (values.ContainsKey("extra"))
         _extra = true;
     if (values.ContainsKey("focus"))
         _focus = true;
     if (values.ContainsKey("type_code"))
         SetType((string)values["type_code"]);
     return true;
 }
예제 #13
0
파일: LaCroix.cs 프로젝트: labeuze/source
 //NamedValues1
 public LaCroix(NamedValues<ZValue> values)
 {
     // year          : mandatory, int or numeric string
     // day           : mandatory, int or numeric string
     // month         : mandatory, int or numeric string
     // number        : not used, int or numeric string
     if (!values.ContainsKey("day_near_current_date"))
     {
         if (!values.ContainsKey("year"))
             throw new PBException("error creating LaCroix unknow year");
         if (!values.ContainsKey("month"))
             throw new PBException("error creating LaCroix unknow month");
         if (!values.ContainsKey("day"))
             throw new PBException("error creating LaCroix unknow day");
     }
     _date = zdate.CreateDate(values);
 }
예제 #14
0
 public static bool GetTestValue(NamedValues <ZValue> parameters)
 {
     if (parameters.ContainsKey("test"))
     {
         return((bool)parameters["test"]);
     }
     return(false);
 }
예제 #15
0
파일: LeMonde0.cs 프로젝트: labeuze/source
 //NamedValues1
 public LeMonde0(NamedValues<ZValue> values)
 {
     // year          : mandatory, int or numeric string
     // day           : mandatory, int or numeric string
     // month         : mandatory, int or numeric string
     // type_quo      : optional, string null, "_quo"
     // types_quo_sup : optional, string[], "tv", "argent"
     // type_sup      : optional, string null, "livres"
     // number        : not used, int or numeric string
     // type          : not used, string "_quo", "-livres", "_quo+tv", "_quo+tv+argent"
     if (!values.ContainsKey("year"))
         throw new PBException("error creating LeMonde unknow year");
     if (!values.ContainsKey("month"))
         throw new PBException("error creating LeMonde unknow month");
     if (!values.ContainsKey("day"))
         throw new PBException("error creating LeMonde unknow day");
     _date = zdate.CreateDate(values);
     _type = GetType(values);
 }
예제 #16
0
 //NamedValues1
 public LeFigaro(NamedValues <ZValue> values)
 {
     if (!values.ContainsKey("day_near_current_date"))
     {
         if (!values.ContainsKey("year"))
         {
             throw new PBException("error creating LeFigaro unknow year");
         }
         if (!values.ContainsKey("month"))
         {
             throw new PBException("error creating LeFigaro unknow month");
         }
         if (!values.ContainsKey("day"))
         {
             throw new PBException("error creating LeFigaro unknow day");
         }
     }
     _date = zdate.CreateDate(values);
 }
예제 #17
0
 //NamedValues1
 public override bool TrySetValues(NamedValues <ZValue> values)
 {
     if (!base.TrySetValues(values))
     {
         return(false);
     }
     if (values.ContainsKey("es"))
     {
         _es = true;
     }
     if (values.ContainsKey("styles"))
     {
         _styles = true;
     }
     if (values.ContainsKey("type_code"))
     {
         //string
         SetType((string)values["type_code"]);
     }
     return(true);
 }
예제 #18
0
파일: LeMonde0.cs 프로젝트: 24/source_04
        //NamedValues1
        public static LeMondeType GetType(NamedValues <ZValue> values)
        {
            LeMondeType type = LeMondeType.Unknow;

            if (values.ContainsKey("type_code"))
            {
                type = GetTypeCode((string)values["type_code"]);
            }
            else if (values.ContainsKey("type_quo") && values["type_quo"] != null)
            {
                type = LeMondeType.Quotidien;
                if (values.ContainsKey("types_quo_sup"))
                {
                    object o = values["types_quo_sup"];
                    if (o != null && !(o is string[]))
                    {
                        throw new PBException("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
                    }
                    foreach (string s in (string[])o)
                    {
                        type |= GetTypeSup(s);
                    }
                }
            }
            else
            {
                if (!values.ContainsKey("type_sup"))
                {
                    throw new PBException("error creating LeMonde unknow type_sup");
                }
                object o = values["type_sup"];
                if (!(o is string))
                {
                    throw new PBException("error creating LeMonde value type_sup should be a string : {0}", o);
                }
                type = GetTypeSup((string)o);
            }
            return(type);
        }
예제 #19
0
 //NamedValues1
 public override bool TrySetValues(NamedValues <ZValue> values)
 {
     if (!base.TrySetValues(values))
     {
         return(false);
     }
     _eco = false;
     _mag = false;
     if (values.ContainsKey("eco"))
     {
         _eco = true;
     }
     if (values.ContainsKey("mag"))
     {
         _mag = true;
     }
     if (values.ContainsKey("type_code"))
     {
         SetType((string)values["type_code"]);
     }
     return(true);
 }
예제 #20
0
 //NamedValues1
 public LaCroix(NamedValues <ZValue> values)
 {
     // year          : mandatory, int or numeric string
     // day           : mandatory, int or numeric string
     // month         : mandatory, int or numeric string
     // number        : not used, int or numeric string
     if (!values.ContainsKey("day_near_current_date"))
     {
         if (!values.ContainsKey("year"))
         {
             throw new PBException("error creating LaCroix unknow year");
         }
         if (!values.ContainsKey("month"))
         {
             throw new PBException("error creating LaCroix unknow month");
         }
         if (!values.ContainsKey("day"))
         {
             throw new PBException("error creating LaCroix unknow day");
         }
     }
     _date = zdate.CreateDate(values);
 }
예제 #21
0
파일: zDay.cs 프로젝트: labeuze/source
 public static bool TryGetDay(NamedValues<ZValue> values, out int day)
 {
     day = 0;
     if (values.ContainsKey("day"))
     {
         ZValue v = values["day"];
         if (v is ZString)
         {
             day = GetDayNumber((string)v);
             if (day != 0)
                 return true;
         }
         else
             Trace.WriteLine("error day should be a string : {0}", v);
     }
     return false;
 }
예제 #22
0
파일: Print1.cs 프로젝트: 24/source_04
        //NamedValues1
        protected virtual bool TryGetPrintNumber(NamedValues <ZValue> values, out int number)
        {
            number = 0;
            if (!values.ContainsKey("number"))
            {
                //throw new PBException("error print number not found");
                values.SetError("error print number not found");
                return(false);
            }
            int number2;

            if (!int.TryParse((string)values["number"], out number2))
            {
                //throw new PBException("error invalid print number \"{0}\"", values["number"]);
                values.SetError("error invalid print number \"{0}\"", values["number"]);
                return(false);
            }
            //return printNumber;
            number = number2;
            return(true);
        }
예제 #23
0
 public static bool TryGetDay(NamedValues <ZValue> values, out int day)
 {
     day = 0;
     if (values.ContainsKey("day"))
     {
         ZValue v = values["day"];
         if (v is ZString)
         {
             day = GetDayNumber((string)v);
             if (day != 0)
             {
                 return(true);
             }
         }
         else
         {
             Trace.WriteLine("error day should be a string : {0}", v);
         }
     }
     return(false);
 }
예제 #24
0
 public FindNumber Find(string text)
 {
     foreach (RegexValues rv in _numberRegexList.Values)
     {
         MatchValues matchValues = rv.Match(text);
         if (matchValues.Success)
         {
             NamedValues <ZValue> values = matchValues.GetValues();
             if (values.ContainsKey("number"))
             {
                 int    number;
                 ZValue value = values["number"];
                 if (value is ZString)
                 {
                     if (!int.TryParse((string)value, out number))
                     {
                         throw new PBException("error finding number text is'nt a number : \"{0}\"", (string)value);
                     }
                 }
                 else if (value is ZInt)
                 {
                     number = (int)value;
                 }
                 else
                 {
                     throw new PBException("error finding number value is'nt a number : {0}", value);
                 }
                 //return new FindNumber { found = true, number = number, remainText = rv.MatchReplace("_"), regexValues = rv };
                 return(new FindNumber {
                     found = true, number = number, matchValues = matchValues
                 });
             }
         }
     }
     return(new FindNumber {
         found = false
     });
 }
예제 #25
0
파일: Print.cs 프로젝트: 24/source_04
        public virtual bool TrySetValues(NamedValues <ZValue> values)
        {
            //_error = null;
            //_printValues.SetValues(values);

            bool special = _special;

            if (values.ContainsKey("special"))
            {
                special = true;
                _printValues.SetValues(values, "special");
            }

            bool specialMonth = _specialMonth;

            if (values.ContainsKey("special_month"))
            {
                specialMonth = true;
                _printValues.SetValues(values, "special_month");
            }

            Date?    date     = _date;
            DateType dateType = _dateType;

            if (values.ContainsKey("day_near_current_date") || values.ContainsKey("month"))
            {
                Date     date2;
                DateType dateType2;
                if (!zdate.TryCreateDate(values, out date2, out dateType2))
                {
                    //if (values.Error != null)
                    //    _error = values.Error;
                    return(false);
                }
                string error;
                if (!ControlDate(date2, out error))
                {
                    return(false);
                }
                date     = date2;
                dateType = dateType2;
                _printValues.SetValues(values, "day_near_current_date", "day", "month", "year");
            }

            int printNumber = _printNumber;

            if (values.ContainsKey("number"))
            {
                if (!TryGetPrintNumber(values, out printNumber))
                {
                    return(false);
                }
                _printValues.SetValues(values, "number");
            }

            if (date != null && printNumber != 0 && !_print.NoDateAndNumberCalculate && !special && !specialMonth)
            {
                if (_print.Frequency == PrintFrequency.Daily)
                {
                    printNumber = 0;
                }
                else
                {
                    date     = null;
                    dateType = pb.DateType.Unknow;
                }
            }

            string label = _label;

            if (values.ContainsKey("label"))
            {
                label = (string)values["label"];
                _printValues.SetValues(values, "label");
            }

            int index = _index;

            if (values.ContainsKey("index"))
            {
                if (!TryGetIndex(values, out index))
                {
                    return(false);
                }
                _printValues.SetValues(values, "index");
            }

            _error        = null;
            _special      = special;
            _specialMonth = specialMonth;
            _date         = date;
            _dateType     = dateType;
            _printNumber  = printNumber;
            _label        = label;
            _index        = index;
            return(true);
        }
예제 #26
0
파일: LeMonde1.cs 프로젝트: labeuze/source
 //NamedValues1
 public static bool TryGetType(NamedValues<ZValue> values, out LeMondeType type)
 {
     type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", (string)values["type_code"]);
             return false;
         }
     }
     else if ((values.ContainsKey("type_quo") && values["type_quo"] != null) || values.ContainsKey("fix_type_quo"))
     //else if (values.ContainsKey("type_quo"))
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             object o = values["types_quo_sup"];
             if (o != null && !(o is string[]))
             {
                 //throw new PBException("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
                 values.SetError("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
                 return false;
             }
             foreach (string s in (string[])o)
             {
                 //type |= GetTypeSup(s);
                 LeMondeType type2 = GetTypeSup(s);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", s);
                     return false;
                 }
                 type |= type2;
             }
         }
     }
     else if (values.ContainsKey("type_sup"))
     {
         //if (!values.ContainsKey("type_sup"))
         //    throw new PBException("error creating LeMonde unknow type_sup");
         object o = values["type_sup"];
         if (!(o is string))
         {
             //throw new PBException("error creating LeMonde value type_sup should be a string : {0}", o);
             values.SetError("error creating LeMonde value type_sup should be a string : {0}", o);
             return false;
         }
         type = GetTypeSup((string)o);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", o);
             return false;
         }
     }
     else if (values.ContainsKey("fix_type_eco"))
         type = LeMondeType.Economie;
     else if (values.ContainsKey("fix_type_tv"))
         type = LeMondeType.TV;
     else
     {
         //throw new PBException("error creating LeMonde unknow type");
         values.SetError("error creating LeMonde unknow type");
         return false;
     }
     //return type;
     return true;
 }
예제 #27
0
        public void SetTextValues(IEnumerable <string> texts)
        {
            string name = null;
            string text = null;

            foreach (string s in texts)
            {
                // PDF | 116 pages | 53 Mb | French
                //Trace.CurrentTrace.WriteLine("SetTextValues : \"{0}\"", s);
                if (s == "\r\n")
                {
                    if (text != null)
                    {
                        if (name != null)
                        {
                            infos.SetValue(name, new ZString(text));
                        }
                        else
                        {
                            description.Add(text);
                        }
                        text = null;
                    }
                    name = null;
                }
                else
                {
                    //string s2 = TelechargementPlus.TrimString(TelechargementPlus.ExtractTextValues(infos, s));
                    string s2 = TelechargementPlus.TrimFunc1(TelechargementPlus.ExtractTextValues(infos, s));
                    if (infos.ContainsKey("language"))
                    {
                        language = (string)infos["language"];
                        infos.Remove("language");
                    }
                    else if (infos.ContainsKey("size"))
                    {
                        size = (string)infos["size"];
                        infos.Remove("size");
                    }
                    else if (infos.ContainsKey("page_nb"))
                    {
                        nbPages = int.Parse((string)infos["page_nb"]);
                        infos.Remove("page_nb");
                    }
                    //Trace.WriteLine("text \"{0}\" => \"{1}\"", s, s2);
                    bool foundName = false;
                    if (s2.EndsWith(":"))
                    {
                        string s3 = s2.Substring(0, s2.Length - 1).Trim();
                        if (s3 != "")
                        {
                            name      = s3;
                            foundName = true;
                        }
                    }
                    //else if (s2 != "" && s2 != title)
                    if (!foundName && s2 != "" && s2 != title)
                    {
                        if (text == null)
                        {
                            text = s2;
                        }
                        else
                        {
                            text += " " + s2;
                        }
                    }
                }
            }
            if (text != null)
            {
                if (name != null)
                {
                    infos.SetValue(name, new ZString(text));
                }
                else
                {
                    description.Add(text);
                }
            }
        }
예제 #28
0
파일: LeMonde.cs 프로젝트: labeuze/source
 // type_code     : quo, arg, arh, dos, mde, edu, aut, peh, liv, mag, mdv, sch, scq, sph, sty, nyt, tel
 // type_quo      :
 // fix_type_quo  :
 // types_quo_sup : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // type_sup      : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // type_sups     : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // fix_type_eco  :
 // fix_type_tv   :
 public static bool TryGetType(NamedValues<ZValue> values, out LeMondeType type)
 {
     type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", values["type_code"]);
             return false;
         }
     }
     else if ((values.ContainsKey("type_quo") && values["type_quo"] != null) || values.ContainsKey("fix_type_quo"))
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             ZValue v = values["types_quo_sup"];
             if (v != null && !(v is ZStringArray))
             {
                 values.SetError("error creating LeMonde value types_quo_sup should be a string array : {0}", v);
                 return false;
             }
             foreach (string s in (string[])v)
             {
                 LeMondeType type2 = GetTypeSup(s);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", s);
                     return false;
                 }
                 type |= type2;
             }
         }
     }
     else if (values.ContainsKey("type_sup"))
     {
         ZValue v = values["type_sup"];
         if (!(v is ZString))
         {
             values.SetError("error creating LeMonde value type_sup should be a string : {0}", v);
             return false;
         }
         type = GetTypeSup((string)v);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", v);
             return false;
         }
     }
     else if (values.ContainsKey("type_sups"))
     {
         ZValue v = values["type_sups"];
         if (v != null)
         {
             if (v is ZString)
             {
                 LeMondeType type2 = GetTypeSup((string)v);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", (string)v);
                     return false;
                 }
                 type = type2;
             }
             else if (v is ZStringArray)
             {
                 type = LeMondeType.Unknow;
                 foreach (string s in (string[])v)
                 {
                     LeMondeType type2 = GetTypeSup(s);
                     if (type2 == LeMondeType.Unknow)
                     {
                         values.SetError("error unknow le monde type sup : \"{0}\"", s);
                         //return false;
                     }
                     else
                         type |= type2;
                 }
             }
             else
             {
                 values.SetError("error creating LeMonde value type_sups should be a string or string array : {0}", v);
                 return false;
             }
         }
     }
     else if (values.ContainsKey("fix_type_eco"))
         type = LeMondeType.Economie;
     else if (values.ContainsKey("fix_type_tv"))
         type = LeMondeType.TV;
     return true;
 }
예제 #29
0
 public static bool GetTestValue(NamedValues<ZValue> parameters)
 {
     if (parameters.ContainsKey("test"))
         return (bool)parameters["test"];
     return false;
 }
예제 #30
0
파일: LeMonde.cs 프로젝트: labeuze/source
        // type_dossier  : name
        public override bool TrySetValues(NamedValues<ZValue> values)
        {
            if (!base.TrySetValues(values))
                return false;

            LeMondeType type;
            if (!TryGetType(values, out type))
                return false;
            if (type != LeMondeType.Unknow)
                _type = type;

            if (values.ContainsKey("type_dossier"))
            {
                ZValue v = values["type_dossier"];
                if (v != null && v is ZString)
                {
                    _dossier = (string)v;
                }
            }

            _typeCode = null;
            return true;
        }
예제 #31
0
파일: Print.cs 프로젝트: labeuze/source
 protected virtual bool TryGetPrintNumber(NamedValues<ZValue> values, out int number)
 {
     number = 0;
     if (!values.ContainsKey("number"))
     {
         SetError("error print number not found");
         return false;
     }
     int number2;
     if (!int.TryParse((string)values["number"], out number2))
     {
         SetError("error invalid print number \"{0}\"", values["number"]);
         return false;
     }
     if (_print.Frequency != PrintFrequency.Daily && !_special)
     {
         //Date date = _print.GetPrintDate(number2);
         Date date;
         DateType dateType;
         _print.GetPrintDate(number2, out date, out dateType);
         string error;
         if (!ControlDate(date, out error))
         {
             return false;
         }
     }
     number = number2;
     return true;
 }
예제 #32
0
파일: Date2.cs 프로젝트: labeuze/source
        public static DateValues GetDateValues(NamedValues<ZValue> values)
        {
            DateValues dateValues = new DateValues();

            ZValue v;
            if (values.ContainsKey("day_near_current_date"))
            {
                v = values["day_near_current_date"];
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    string s = (string)v;
                    s = s.Replace('o', '0');
                    s = s.Replace('O', '0');
                    int day;
                    if (int.TryParse(s, out day))
                        dateValues.dayNearCurrentDate = day;
                    else
                    {
                        //values.SetError("error creating Date day_near_current_date is'nt a number : \"{0}\"", v);
                        Trace.WriteLine("error creating Date day_near_current_date is'nt a number : \"{0}\"", v);
                        //return false;
                    }
                }
                else if (v is ZInt)
                    //day = (int)v;
                    dateValues.dayNearCurrentDate = (int)v;
                else
                {
                    //values.SetError("error creating Date day_near_current_date should be a string number or an int : {0}", v);
                    Trace.WriteLine("error creating Date day_near_current_date should be a string number or an int : {0}", v);
                    //return false;
                }
            }

            //string name = null;
            //if (values.ContainsKey("year"))
            //    name = "year";
            //else if (values.ContainsKey("year1"))
            //    name = "year1";
            //else if (values.ContainsKey("year2"))
            //    name = "year2";

            v = null;
            if (values.ContainsKey("year1"))
            {
                v = values["year1"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }
            if (v == null && values.ContainsKey("year2"))
            {
                v = values["year2"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }
            if (v == null && values.ContainsKey("year"))
            {
                v = values["year"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }

            if (v != null)
            {
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    int year;
                    if (int.TryParse((string)v, out year))
                        dateValues.year = year;
                    else
                    {
                        //values.SetError("error creating Date year is'nt a number : \"{0}\"", v);
                        Trace.WriteLine("error creating Date year is'nt a number : \"{0}\"", v);
                        //return false;
                    }
                }
                else if (v is ZInt)
                    dateValues.year = (int)v;
                else if (v != null)
                {
                    //values.SetError("error creating Date year should be a string number or an int : {0}", v);
                    Trace.WriteLine("error creating Date year should be a string number or an int : {0}", v);
                    //return false;
                }
            }



            v = null;
            if (values.ContainsKey("month1"))
            {
                v = values["month1"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }
            if (v == null && values.ContainsKey("month2"))
            {
                v = values["month2"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }
            if (v == null && values.ContainsKey("month"))
            {
                v = values["month"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }

            if (v != null)
            {
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    int month;
                    if (int.TryParse((string)v, out month))
                        dateValues.month = month;
                    else
                    {
                        month = zdate.GetMonthNumber((string)v);
                        if (month != 0)
                            dateValues.month = month;
                        else
                        {
                            //values.SetError("error creating Date invalid month : \"{0}\"", v);
                            Trace.WriteLine("error creating Date invalid month : \"{0}\"", v);
                            //return false;
                        }
                    }
                }
                else if (v is ZInt)
                    dateValues.month = (int)v;
                else if (v != null)
                {
                    //values.SetError("error creating Date month should be a string number or an int : {0}", v);
                    Trace.WriteLine("error creating Date month should be a string number or an int : {0}", v);
                    //return false;
                }
            }


            if (values.ContainsKey("day"))
            {
                v = values["day"];
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    int day;
                    //if ((string)v == "1er")
                    if (string.Equals((string)v, "1er", StringComparison.InvariantCultureIgnoreCase))
                        dateValues.day = 1;
                    else if (int.TryParse((string)v, out day))
                        dateValues.day = day;
                    else
                    {
                        //values.SetError("error creating Date day is'nt a number : \"{0}\"", v);
                        Trace.WriteLine("error creating Date day is'nt a number : \"{0}\"", v);
                        //return false;
                    }
                }
                else if (v is ZInt)
                {
                    dateValues.day = (int)v;
                }
                else if (v != null)
                {
                    //values.SetError("error creating Date day should be a string number or an int : {0}", v);
                    //Trace.WriteLine("error creating Date day should be a string number or an int : value {0} type {1}", v != null ? v : "(null)", v != null ? v.GetType().zName() : "(null)");
                    Trace.WriteLine("error creating Date day should be a string number or an int : value {0} type {1}", v, v.GetType().zGetTypeName());
                    //return false;
                }
            }



            return dateValues;
        }
예제 #33
0
        public static DateValues GetDateValues(NamedValues <ZValue> values)
        {
            DateValues dateValues = new DateValues();

            ZValue v;

            if (values.ContainsKey("day_near_current_date"))
            {
                v = values["day_near_current_date"];
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    string s = (string)v;
                    s = s.Replace('o', '0');
                    s = s.Replace('O', '0');
                    int day;
                    if (int.TryParse(s, out day))
                    {
                        dateValues.dayNearCurrentDate = day;
                    }
                    else
                    {
                        //values.SetError("error creating Date day_near_current_date is'nt a number : \"{0}\"", v);
                        Trace.WriteLine("error creating Date day_near_current_date is'nt a number : \"{0}\"", v);
                        //return false;
                    }
                }
                else if (v is ZInt)
                {
                    //day = (int)v;
                    dateValues.dayNearCurrentDate = (int)v;
                }
                else
                {
                    //values.SetError("error creating Date day_near_current_date should be a string number or an int : {0}", v);
                    Trace.WriteLine("error creating Date day_near_current_date should be a string number or an int : {0}", v);
                    //return false;
                }
            }

            //string name = null;
            //if (values.ContainsKey("year"))
            //    name = "year";
            //else if (values.ContainsKey("year1"))
            //    name = "year1";
            //else if (values.ContainsKey("year2"))
            //    name = "year2";

            v = null;
            if (values.ContainsKey("year1"))
            {
                v = values["year1"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                {
                    v = null;
                }
            }
            if (v == null && values.ContainsKey("year2"))
            {
                v = values["year2"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                {
                    v = null;
                }
            }
            if (v == null && values.ContainsKey("year"))
            {
                v = values["year"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                {
                    v = null;
                }
            }

            if (v != null)
            {
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    int year;
                    if (int.TryParse((string)v, out year))
                    {
                        dateValues.year = year;
                    }
                    else
                    {
                        //values.SetError("error creating Date year is'nt a number : \"{0}\"", v);
                        Trace.WriteLine("error creating Date year is'nt a number : \"{0}\"", v);
                        //return false;
                    }
                }
                else if (v is ZInt)
                {
                    dateValues.year = (int)v;
                }
                else if (v != null)
                {
                    //values.SetError("error creating Date year should be a string number or an int : {0}", v);
                    Trace.WriteLine("error creating Date year should be a string number or an int : {0}", v);
                    //return false;
                }
            }



            v = null;
            if (values.ContainsKey("month1"))
            {
                v = values["month1"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                {
                    v = null;
                }
            }
            if (v == null && values.ContainsKey("month2"))
            {
                v = values["month2"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                {
                    v = null;
                }
            }
            if (v == null && values.ContainsKey("month"))
            {
                v = values["month"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                {
                    v = null;
                }
            }

            if (v != null)
            {
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    int month;
                    if (int.TryParse((string)v, out month))
                    {
                        dateValues.month = month;
                    }
                    else
                    {
                        month = zdate.GetMonthNumber((string)v);
                        if (month != 0)
                        {
                            dateValues.month = month;
                        }
                        else
                        {
                            //values.SetError("error creating Date invalid month : \"{0}\"", v);
                            Trace.WriteLine("error creating Date invalid month : \"{0}\"", v);
                            //return false;
                        }
                    }
                }
                else if (v is ZInt)
                {
                    dateValues.month = (int)v;
                }
                else if (v != null)
                {
                    //values.SetError("error creating Date month should be a string number or an int : {0}", v);
                    Trace.WriteLine("error creating Date month should be a string number or an int : {0}", v);
                    //return false;
                }
            }


            if (values.ContainsKey("day"))
            {
                v = values["day"];
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    int day;
                    //if ((string)v == "1er")
                    if (string.Equals((string)v, "1er", StringComparison.InvariantCultureIgnoreCase))
                    {
                        dateValues.day = 1;
                    }
                    else if (int.TryParse((string)v, out day))
                    {
                        dateValues.day = day;
                    }
                    else
                    {
                        //values.SetError("error creating Date day is'nt a number : \"{0}\"", v);
                        Trace.WriteLine("error creating Date day is'nt a number : \"{0}\"", v);
                        //return false;
                    }
                }
                else if (v is ZInt)
                {
                    dateValues.day = (int)v;
                }
                else if (v != null)
                {
                    //values.SetError("error creating Date day should be a string number or an int : {0}", v);
                    //Trace.WriteLine("error creating Date day should be a string number or an int : value {0} type {1}", v != null ? v : "(null)", v != null ? v.GetType().zName() : "(null)");
                    Trace.WriteLine("error creating Date day should be a string number or an int : value {0} type {1}", v, v.GetType().zGetTypeName());
                    //return false;
                }
            }



            return(dateValues);
        }
예제 #34
0
파일: Print1.cs 프로젝트: labeuze/source
 //NamedValues1
 protected virtual bool TryGetIndex(NamedValues<ZValue> values, out int index)
 {
     index = 0;
     if (!values.ContainsKey("index"))
     {
         //throw new PBException("error index not found");
         values.SetError("error index not found");
         return false;
     }
     string s = (string)values["index"];
     if (s == null)
         //return 0;
         return true;
     int index2;
     if (!int.TryParse(s, out index2))
     {
         //throw new PBException("error invalid index \"{0}\"", s);
         values.SetError("error invalid index \"{0}\"", s);
         return false;
     }
     //return index;
     index = index2;
     return true;
 }
예제 #35
0
 // type_code     : quo, arg, arh, dos, mde, edu, aut, peh, liv, mag, mdv, sch, scq, sph, sty, nyt, tel
 // type_quo      :
 // fix_type_quo  :
 // types_quo_sup : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // type_sup      : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // type_sups     : argent, culture, dossier, éco, eco, édu, edu, festival, géo, geo, livres, mag, mode, science, sport, style, nyt, tv, document, élection, election, hebdo, sup
 // fix_type_eco  :
 // fix_type_tv   :
 public static bool TryGetType(NamedValues <ZValue> values, out LeMondeType type)
 {
     type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", values["type_code"]);
             return(false);
         }
     }
     else if ((values.ContainsKey("type_quo") && values["type_quo"] != null) || values.ContainsKey("fix_type_quo"))
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             ZValue v = values["types_quo_sup"];
             if (v != null && !(v is ZStringArray))
             {
                 values.SetError("error creating LeMonde value types_quo_sup should be a string array : {0}", v);
                 return(false);
             }
             foreach (string s in (string[])v)
             {
                 LeMondeType type2 = GetTypeSup(s);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", s);
                     return(false);
                 }
                 type |= type2;
             }
         }
     }
     else if (values.ContainsKey("type_sup"))
     {
         ZValue v = values["type_sup"];
         if (!(v is ZString))
         {
             values.SetError("error creating LeMonde value type_sup should be a string : {0}", v);
             return(false);
         }
         type = GetTypeSup((string)v);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", v);
             return(false);
         }
     }
     else if (values.ContainsKey("type_sups"))
     {
         ZValue v = values["type_sups"];
         if (v != null)
         {
             if (v is ZString)
             {
                 LeMondeType type2 = GetTypeSup((string)v);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", (string)v);
                     return(false);
                 }
                 type = type2;
             }
             else if (v is ZStringArray)
             {
                 type = LeMondeType.Unknow;
                 foreach (string s in (string[])v)
                 {
                     LeMondeType type2 = GetTypeSup(s);
                     if (type2 == LeMondeType.Unknow)
                     {
                         values.SetError("error unknow le monde type sup : \"{0}\"", s);
                         //return false;
                     }
                     else
                     {
                         type |= type2;
                     }
                 }
             }
             else
             {
                 values.SetError("error creating LeMonde value type_sups should be a string or string array : {0}", v);
                 return(false);
             }
         }
     }
     else if (values.ContainsKey("fix_type_eco"))
     {
         type = LeMondeType.Economie;
     }
     else if (values.ContainsKey("fix_type_tv"))
     {
         type = LeMondeType.TV;
     }
     return(true);
 }
예제 #36
0
 //NamedValues1
 public static bool TryGetType(NamedValues <ZValue> values, out LeMondeType type)
 {
     type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", (string)values["type_code"]);
             return(false);
         }
     }
     else if ((values.ContainsKey("type_quo") && values["type_quo"] != null) || values.ContainsKey("fix_type_quo"))
     //else if (values.ContainsKey("type_quo"))
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             object o = values["types_quo_sup"];
             if (o != null && !(o is string[]))
             {
                 //throw new PBException("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
                 values.SetError("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
                 return(false);
             }
             foreach (string s in (string[])o)
             {
                 //type |= GetTypeSup(s);
                 LeMondeType type2 = GetTypeSup(s);
                 if (type2 == LeMondeType.Unknow)
                 {
                     values.SetError("error unknow le monde type sup : \"{0}\"", s);
                     return(false);
                 }
                 type |= type2;
             }
         }
     }
     else if (values.ContainsKey("type_sup"))
     {
         //if (!values.ContainsKey("type_sup"))
         //    throw new PBException("error creating LeMonde unknow type_sup");
         object o = values["type_sup"];
         if (!(o is string))
         {
             //throw new PBException("error creating LeMonde value type_sup should be a string : {0}", o);
             values.SetError("error creating LeMonde value type_sup should be a string : {0}", o);
             return(false);
         }
         type = GetTypeSup((string)o);
         if (type == LeMondeType.Unknow)
         {
             values.SetError("error unknow le monde type sup : \"{0}\"", o);
             return(false);
         }
     }
     else if (values.ContainsKey("fix_type_eco"))
     {
         type = LeMondeType.Economie;
     }
     else if (values.ContainsKey("fix_type_tv"))
     {
         type = LeMondeType.TV;
     }
     else
     {
         //throw new PBException("error creating LeMonde unknow type");
         values.SetError("error creating LeMonde unknow type");
         return(false);
     }
     //return type;
     return(true);
 }
예제 #37
0
파일: Print1.cs 프로젝트: labeuze/source
        //NamedValues1
        public virtual bool TrySetValues(NamedValues<ZValue> values)
        {
            //_special
            //NewIssue();
            //if (values.ContainsKey("special_month"))
            //{
            //    _special_month = true;
            //    _date = date.CreateDate(values);
            //    _printNumber = GetPrintNumber(values);
            //}
            //else
            //{
            //    if (values.ContainsKey("day_near_current_date") || values.ContainsKey("year") || values.ContainsKey("month") || values.ContainsKey("day"))
            //        _date = date.CreateDate(values);
            //    if (values.ContainsKey("number"))
            //    {
            //        _printNumber = GetPrintNumber(values);
            //    }
            //}
            //_printValues = values;
            if (values.ContainsKey("special"))
                _special = true;
            if (values.ContainsKey("special_month"))
                _specialMonth = true;
            //bool setDate = false;
            //if (values.ContainsKey("day_near_current_date") || values.ContainsKey("year") || values.ContainsKey("month") || values.ContainsKey("day"))
            if (values.ContainsKey("day_near_current_date") || values.ContainsKey("month"))
            {
                //_date = date.CreateDate(values);
                //setDate = true;
                Date date;
                DateType dateType;
                if (!zdate.TryCreateDate(values, out date, out dateType))
                    return false;
                _date = date;
            }
            if (values.ContainsKey("number"))
            {
                //if (!setDate || _noDateAndNumberCalculate)
                //_printNumber = GetPrintNumber(values);
                if (!TryGetPrintNumber(values, out _printNumber))
                    return false;
            }
            if (_date != null && _printNumber != 0 && !_noDateAndNumberCalculate && !_special && !_specialMonth)
            {
                if (_frequency == PrintFrequency.Daily)
                    _printNumber = 0;
                else
                    _date = null;
            }

            if (values.ContainsKey("label"))
                _label = (string)values["label"];
            if (values.ContainsKey("index"))
            {
                //_index = GetIndex(values);
                if (!TryGetIndex(values, out _index))
                    return false;
            }
            _printValues.SetValues(values);
            return true;
        }
예제 #38
0
파일: Print.cs 프로젝트: labeuze/source
        public virtual bool TrySetValues(NamedValues<ZValue> values)
        {
            //_error = null;
            //_printValues.SetValues(values);

            bool special = _special;
            if (values.ContainsKey("special"))
            {
                special = true;
                _printValues.SetValues(values, "special");
            }

            bool specialMonth = _specialMonth;
            if (values.ContainsKey("special_month"))
            {
                specialMonth = true;
                _printValues.SetValues(values, "special_month");
            }

            Date? date = _date;
            DateType dateType = _dateType;
            if (values.ContainsKey("day_near_current_date") || values.ContainsKey("month"))
            {
                Date date2;
                DateType dateType2;
                if (!zdate.TryCreateDate(values, out date2, out dateType2))
                {
                    //if (values.Error != null)
                    //    _error = values.Error;
                    return false;
                }
                string error;
                if (!ControlDate(date2, out error))
                    return false;
                date = date2;
                dateType = dateType2;
                _printValues.SetValues(values, "day_near_current_date", "day", "month", "year");
            }

            int printNumber = _printNumber;
            if (values.ContainsKey("number"))
            {
                if (!TryGetPrintNumber(values, out printNumber))
                    return false;
                _printValues.SetValues(values, "number");
            }

            if (date != null && printNumber != 0 && !_print.NoDateAndNumberCalculate && !special && !specialMonth)
            {
                if (_print.Frequency == PrintFrequency.Daily)
                    printNumber = 0;
                else
                {
                    date = null;
                    dateType = pb.DateType.Unknow;
                }
            }

            string label = _label;
            if (values.ContainsKey("label"))
            {
                label = (string)values["label"];
                _printValues.SetValues(values, "label");
            }

            int index = _index;
            if (values.ContainsKey("index"))
            {
                if (!TryGetIndex(values, out index))
                    return false;
                _printValues.SetValues(values, "index");
            }

            _error = null;
            _special = special;
            _specialMonth = specialMonth;
            _date = date;
            _dateType = dateType;
            _printNumber = printNumber;
            _label = label;
            _index = index;
            return true;
        }
예제 #39
0
파일: Print1.cs 프로젝트: labeuze/source
 //NamedValues1
 protected virtual bool TryGetPrintNumber(NamedValues<ZValue> values, out int number)
 {
     number = 0;
     if (!values.ContainsKey("number"))
     {
         //throw new PBException("error print number not found");
         values.SetError("error print number not found");
         return false;
     }
     int number2;
     if (!int.TryParse((string)values["number"], out number2))
     {
         //throw new PBException("error invalid print number \"{0}\"", values["number"]);
         values.SetError("error invalid print number \"{0}\"", values["number"]);
         return false;
     }
     //return printNumber;
     number = number2;
     return true;
 }
예제 #40
0
파일: Print1.cs 프로젝트: 24/source_04
        //NamedValues1
        public virtual bool TrySetValues(NamedValues <ZValue> values)
        {
            //_special
            //NewIssue();
            //if (values.ContainsKey("special_month"))
            //{
            //    _special_month = true;
            //    _date = date.CreateDate(values);
            //    _printNumber = GetPrintNumber(values);
            //}
            //else
            //{
            //    if (values.ContainsKey("day_near_current_date") || values.ContainsKey("year") || values.ContainsKey("month") || values.ContainsKey("day"))
            //        _date = date.CreateDate(values);
            //    if (values.ContainsKey("number"))
            //    {
            //        _printNumber = GetPrintNumber(values);
            //    }
            //}
            //_printValues = values;
            if (values.ContainsKey("special"))
            {
                _special = true;
            }
            if (values.ContainsKey("special_month"))
            {
                _specialMonth = true;
            }
            //bool setDate = false;
            //if (values.ContainsKey("day_near_current_date") || values.ContainsKey("year") || values.ContainsKey("month") || values.ContainsKey("day"))
            if (values.ContainsKey("day_near_current_date") || values.ContainsKey("month"))
            {
                //_date = date.CreateDate(values);
                //setDate = true;
                Date     date;
                DateType dateType;
                if (!zdate.TryCreateDate(values, out date, out dateType))
                {
                    return(false);
                }
                _date = date;
            }
            if (values.ContainsKey("number"))
            {
                //if (!setDate || _noDateAndNumberCalculate)
                //_printNumber = GetPrintNumber(values);
                if (!TryGetPrintNumber(values, out _printNumber))
                {
                    return(false);
                }
            }
            if (_date != null && _printNumber != 0 && !_noDateAndNumberCalculate && !_special && !_specialMonth)
            {
                if (_frequency == PrintFrequency.Daily)
                {
                    _printNumber = 0;
                }
                else
                {
                    _date = null;
                }
            }

            if (values.ContainsKey("label"))
            {
                _label = (string)values["label"];
            }
            if (values.ContainsKey("index"))
            {
                //_index = GetIndex(values);
                if (!TryGetIndex(values, out _index))
                {
                    return(false);
                }
            }
            _printValues.SetValues(values);
            return(true);
        }