Ejemplo n.º 1
0
 public static settings read_settings(core c, db_provider conn)
 {
     return(new settings(conn.dt_table(c.config.get_query("lib-base.get-settings").text)
                         .Rows.Cast <DataRow>().Select(r => new setting((int)r["setting_id"]
                                                                        , (string)r["setting_name"], db_provider.str_val(r["setting_var"])
                                                                        , db_provider.str_val(r["machine_name"]))).ToList()));
 }
Ejemplo n.º 2
0
        public static doc_task open_index(core c, string folder_path)
        {
            doc_task res    = null;
            string   i_name = c.config.get_var("lib-vars.index-folder").value
            , fp            = Path.Combine(folder_path, i_name);

            return(File.Exists(fp) ? new doc_task(fp) : null);
        }
Ejemplo n.º 3
0
        public void save_into_folder(core c, string folder_path)
        {
            string i_name = c.config.get_var("lib-vars.index-folder").value
            , fp          = Path.Combine(folder_path, i_name);

            this.save(fp);

            FileInfo fi = new FileInfo(fp); _lwt = sys.without_ms(fi.LastWriteTime);
        }
Ejemplo n.º 4
0
        public static setting get_setting(core c, db_provider conn, string setting_name)
        {
            DataRow r = conn.first_row(c.parse_query("lib-base.get-setting", new string[, ] {
                { "setting-name", setting_name }
            }));

            return(r == null ? null : new setting((int)r["setting_id"], (string)r["setting_name"]
                                                  , db_provider.str_val(r["setting_var"]), db_provider.str_val(r["machine_name"])));
        }
Ejemplo n.º 5
0
        public static doc_task create_index(core c, string folder_path)
        {
            doc_task res = new doc_task()
            {
                xml = "<root/>", created = true
            };
            string i_name = c.config.get_var("lib-vars.index-folder").value
            , fp          = Path.Combine(folder_path, i_name);

            res.save(fp);
            return(res);
        }
Ejemplo n.º 6
0
 public static bool exists_index(core c, string folder_path)
 {
     return(File.Exists(Path.Combine(folder_path, c.config.get_var("lib-vars.index-folder").value)));
 }
Ejemplo n.º 7
0
 public bo(db_provider conn, core c, config cfg, int user_id = 0, string user_name = "")
 {
     this.db_conn = conn; this.core = c; this.config = cfg; this.user_id = user_id; this.user_name = user_name;
 }
Ejemplo n.º 8
0
        static public task parse_task(core c, int synch_folder_id, string path, DateTime ct, DateTime lwt
                                      , List <string> users, List <free_label> labels, long?folder_id = null, long?file_id = null, bool set_index = false)
        {
            try {
                if (!folder_id.HasValue && !file_id.HasValue)
                {
                    throw new Exception("il task dev'essere un file o un folder");
                }

                string[] parts = Path.GetFileName(path).Split(new char[] { '.' });
                if (parts.Length <= 1)
                {
                    return(null);
                }

                // task
                if (folder_id.HasValue && parts[parts.Length - 1] != "task")
                {
                    return(null);
                }
                else if (file_id.HasValue && parts[parts.Length - 1] != "task" && parts[parts.Length - 2] != "task")
                {
                    return(null);
                }

                // leggo il doc. indice
                doc_task it = null;
                if (folder_id.HasValue && set_index)
                {
                    it = doc_task.exists_index(c, path) ? doc_task.open_index(c, path) : doc_task.create_index(c, path);
                }

                // parse nome cartella
                string title = "", user = it != null ? it.user : "", stato = it != null ? it.stato : "", priorita = it != null ? it.priorita : ""
                , tipo = it != null ? it.tipo : "", stima = it != null ? it.stima : "";
                DateTime?dt = null, dt2 = null;
                for (int i = 0; i < parts.Length; i++)
                {
                    string p = parts[i]; if (p == "task")
                    {
                        break;
                    }

                    // date
                    if (dn_lib.tools.strings.is_int(p) && (p.Length == 6 || p.Length == 8))
                    {
                        if (!dt.HasValue)
                        {
                            parse_date(p, out dt);
                        }
                        else if (!dt2.HasValue)
                        {
                            parse_date(p, out dt2);
                        }
                        if (dt.HasValue && dt2.HasValue && dt2 < dt)
                        {
                            DateTime tmp = dt2.Value; dt = dt2; dt2 = tmp;
                        }
                        if (it != null && it.created && dt.HasValue)
                        {
                            it.dt_create = dt;
                        }
                        if (it != null && it.created && dt2.HasValue)
                        {
                            it.dt_upd = dt2;
                        }
                        continue;
                    }

                    // state
                    free_label lbl = labels.FirstOrDefault(x => !string.IsNullOrEmpty(x.stato) && x.free_txt.ToLower() == p.ToLower());
                    if (lbl != null)
                    {
                        stato = lbl.stato; if (it != null)
                        {
                            it.stato = stato;
                        }
                        continue;
                    }

                    // priorita
                    lbl = labels.FirstOrDefault(x => !string.IsNullOrEmpty(x.priorita) && x.free_txt.ToLower() == p.ToLower());
                    if (lbl != null)
                    {
                        priorita = lbl.priorita; if (it != null)
                        {
                            it.priorita = priorita;
                        }
                        continue;
                    }

                    // tipo
                    lbl = labels.FirstOrDefault(x => !string.IsNullOrEmpty(x.tipo) && x.free_txt.ToLower() == p.ToLower());
                    if (lbl != null)
                    {
                        tipo = lbl.tipo; if (it != null)
                        {
                            it.tipo = tipo;
                        }
                        continue;
                    }

                    // stima
                    lbl = labels.FirstOrDefault(x => !string.IsNullOrEmpty(x.stima) && x.free_txt.ToLower() == p.ToLower());
                    if (lbl != null)
                    {
                        stima = lbl.stima; if (it != null)
                        {
                            it.stima = stima;
                        }
                        continue;
                    }

                    // user
                    if (user == "" && users.FirstOrDefault(x => x.ToLower() == p.ToLower()) != null)
                    {
                        user = p; if (it != null)
                        {
                            it.user = user;
                        }
                        continue;
                    }

                    // title
                    if (title == "")
                    {
                        title = p;
                    }
                }

                return(new task(synch_folder_id, file_id, folder_id, title, user, stato, priorita, tipo, stima
                                , it != null ? it.dt_create : (dt.HasValue ? dt : ct), it != null ? it.dt_upd : (DateTime?)null, lwt, it)
                {
                    path = path
                });
            } catch (Exception ex) { log.log_err(ex); return(null); }
        }
Ejemplo n.º 9
0
 public synch(db_provider conn, core c, config cfg, int user_id = 0, string user_name = "")
     : base(conn, c, cfg, user_id, user_name)
 {
 }